package com.example.wanjinyou.controller;


import com.example.wanjinyou.service.ArticleService;
import com.example.wanjinyou.vo.ArticleVo;
import com.example.wanjinyou.vo.Result;
import com.example.wanjinyou.vo.params.PageParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

@RestController
@RequestMapping("/articles")
public class ArticleController {

    @Autowired
    ArticleService articleService;
    /**
     * 首页文章列表
     * @param pageParams
     * @return
     */
    @PostMapping
    public Result listArticle( @RequestBody  PageParams pageParams)  {
        return articleService.listArticle(pageParams);
    }

    /**
     * 最热文章( 浏览量最高的 前五个)
     */
    @PostMapping("hot")
    public Result hotArticle( ) {
        int limit = 5;
        return articleService.hotArticle(limit);
    }

    /**
     * 查看文章详情
     */
    @PostMapping("view/{id}")
    public Result findArticleBodyById( @PathVariable("id") Long id) {
        return articleService.findArtileBodyById(id);

    }

}

